const Router = require('koa-router');
const router = new Router();
// 视图渲染
const nunjucks = require('nunjucks');
// 基础配置文件
const config = require('../config/config');

/**
 * 请求首页
*/
router.get('/', async (ctx, next) => {
    if(!ctx.cookies.get('author')){
        return ctx.redirect('/login');
    }
    const html = nunjucks.render(config.BASE_PATH + '/../views/index.html');
    ctx.body = html;
})

/**
 * 登录页面
*/
router.get('/login', async (ctx, next) => {
    const html = nunjucks.render(config.BASE_PATH + '/../views/login/index.html', {title: 'hello'});
    ctx.body = html;
})

module.exports = router;
